package cn.hl.hm.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import cn.hl.hm.entity.backstage.BackStageRoleMenu;
import cn.hl.hm.entity.backstage.BackStageRoles;

public interface BackStageRolesMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(BackStageRoles record);

    int insertSelective(BackStageRoles record);

    BackStageRoles selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(BackStageRoles record);

    int updateByPrimaryKey(BackStageRoles record);
    @Select("select role_name as roleName,id as id ,role_flag as roleFlag from t_backstage_roles")
    List<BackStageRoles>  selectAllRoles();
    @Select("select r.id as id,r.role_name as roleName FROM t_backstage_user_role ur,t_backstage_roles r WHERE ur.user_id = #{userId} AND ur.role_id = r.id")
    List<BackStageRoles>  selectUserRoles(Integer userId);
    
    //根据用户名查id
    BackStageRoles selectByroleName(BackStageRoles  roleName);
    
    int insertRoleMenu(BackStageRoleMenu role);
    
    //修改角色权限前先删除源数据 
//    @Delete("delete  from t_backstage_role_menus where role_id={#roleId} ")
    int deleteByRoleId(@Param("roleId") Integer roleId);


}